#include <stdio.h>
#include <unistd.h>
#include "redisop.h"

int main( int argc, char ** argv )
{
    bool bRet = false;

    ServerInfo  sinfo; // redis server info
    memcpy( sinfo.szIp, "127.0.0.1", 9 );
    sinfo.iPort = 6379;

    CRedisOp    CReOp; 
    char * szVal = NULL;

    if( argc<2 )
    {
        printf( "arguments error.\n" );
        return -2;
    }

    bRet = CReOp.Init( (void*)&sinfo ); // set redis server arguments
    if( !bRet )
    {
        printf( "init Redis server error.\n" );
        return -1;
    }

    //const char szTestValue[] = "aven\babc\025\0\0\0\0 0\rabc\0";
    //const char szTestValue[] = "aven";
    //int iRet = CReOp.SetData( argv[1],  szTestValue, sizeof(szTestValue)-1 );
    //int iRet = CReOp.SetDataTest( argv[1],  szTestValue );

    int iRet = 0;
    //if( iRet==0 )
    {
        iRet = CReOp.GetResult( argv[1], &szVal );
        printf( "len:%d, value:%s.\n", iRet, szVal );
    }

	return 0;
}

